package com.cn.dao.grzx;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.cn.conn.DataManager;
import com.cn.conn.ParamSet;
import com.cn.conn.RowDatas;
import com.cn.entity.grzx_page_entity;
import com.sun.org.apache.bcel.internal.generic.RETURN;

import sun.java2d.pipe.GeneralCompositePipe;

public class grzx_pageDao extends DataManager {
	private RowDatas<grzx_page_entity> gpe;
	
	public grzx_pageDao(){
		this.gpe = new gpeDatas();
	}
	
	public List<grzx_page_entity> getMemberInfo(String username){
		String sql="select i.integral,i.a_integral,(SELECT COUNT(*) from tb_coupon_coupontype cc  WHERE cc.user_id= u.id),u.account_balance FROM tb_user u  LEFT JOIN tb_integral i ON i.id=u.member_points  "
				+ "WHERE u.name=?";
		return queryList(sql, new ParamSet(username), gpe);
	}
	
	private  class gpeDatas implements RowDatas<grzx_page_entity>{
		@Override
		public grzx_page_entity getRowData(ResultSet rs) throws SQLException {
			grzx_page_entity gpentity = new grzx_page_entity();
			gpentity.setIntegral(rs.getInt(1));
			gpentity.setAintegral(rs.getInt(2));
			gpentity.setCoupon_length(rs.getInt(3));
			gpentity.setUserbalance(rs.getDouble(4));
			
			return gpentity;
		}
	}

	
 }
